#!/bin/bash

# release note
# 09/09/16 frist release.
# 09/09/17 add an awk module to filter the number

# set varialbes
logfile=/var/log/pppoe.log
rfile=telnum

# script 
cat $logfile | grep user |\
sed 's/\(.*\)"\(.*\)"\(.*\)"\(.*\)"\(.*\)/\2\ \4/' |\
sort | uniq |\
awk 'substr($1,1,1) == "~"{
$1=substr($1,3)
}
substr($1,6) != $2 {
print $1,$2
}' |\
tee $rfile
cat $rfile | wc -l

